<template>
  <view>
    <web-view v-if="url" :src="url"></web-view>
  </view>
</template>
<script setup>
import { onLoad, onShow } from "@dcloudio/uni-app";
import { useUserStore } from "@/store/user";
import { ref } from "vue";
const userStore = useUserStore();
let scene = ""; // 门店代号
let cc = ""; // 门店秘钥
let Minurl = "";
const url = ref("");
onLoad((options) => {
  console.log("onLoad OfficialAuthorization", options);
  scene = options.scene;
  cc = options.cc;
  Minurl = options.Minurl;
});
onShow(async () => {
  console.log("onShow OfficialAuthorization");
  if (userStore.isLogin) {
    // TODO 验证门店代号和秘钥
    // 打开授权页面
    if (scene && scene.indexOf(":") > - 1) {
      scene = scene.split(":")[0];
    }
    url.value = `https://gss.api.holyes.com/gss2.0https/GetOpenID.html?tSence=${encodeURIComponent(scene)}&url=${encodeURIComponent(Minurl)}`
    console.log('open', url.value)
  } else {
    uni.navigateTo({
      url: "/subpages/account/login",
    });
  }
});
</script>